package com.thunbu.thunbu_meeting_system.activity

import com.cathu.lib_commonkt.base.BaseMVVMActivity
import com.thunbu.lib_common.widget.CommonToolBar
import com.thunbu.thunbu_meeting_system.R
import com.thunbu.thunbu_meeting_system.databinding.ActivitySettingBinding
import com.thunbu.thunbu_meeting_system.utils.AppUtils
import com.thunbu.thunbu_meeting_system.viewMdel.SettingViewModel

/**
 * 设置
 */
class SettingActivity: BaseMVVMActivity<ActivitySettingBinding,SettingViewModel>() {

    lateinit var toolBar: CommonToolBar


    override fun onMVVMCreated() {
        initToolBar()
        initView()
        vm.success.observe(this){
            AppUtils.loginOut()
        }
    }

    private fun initView() {
        bindViews.tvName.text = AppUtils.getUserInfo()?.name
        bindViews.tvPhone.text = AppUtils.getUserInfo()?.phoneNumber
        bindViews.tvCompany.text = AppUtils.getUserInfo()?.unitName
        bindViews.ivHeadPic.setImageResource(R.mipmap.default_icon_female)
        bindViews.tvLogout.setOnClickListener {
            vm.doLoginOut()
        }
    }

    private fun initToolBar() {
        toolBar = setToolBar(CommonToolBar::class.java)
        toolBar.setBackAction { finish() }
        toolBar.setTitle(getString(R.string.title2))
    }
}